"""
规格管理序列化器
"""

from rest_framework import serializers
from goods.models import SPUSpecification

class SPUSpecificationSerializer(serializers.ModelSerializer):

    spu = serializers.StringRelatedField()
    spu_id = serializers.IntegerField()
    class Meta:
        model = SPUSpecification
        fields = ['id', 'name', 
        'spu', # 序列化规格（从表）的同时，嵌套序列化SPU（主表）单一对象
        'spu_id']
